<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.ag.contactTree.*"%>
<%@page import="com.ag.zhh.vo.*"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title></title>
		<meta content="text/html; charset=UTF-8" http-equiv="content-type">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">		
		<link rel="stylesheet" href="../jquery-treeview/jquery.treeview.css" />
		<link rel="stylesheet" href="../zhh/css/utils.css" />
		
		<script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
		<script src="../jquery-treeview/lib/jquery.cookie.js" type="text/javascript"></script>
		<script src="../jquery-treeview/jquery.treeview.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function(){
				$("#MedicineTree").treeview({animated:"medium", control:"#contreecontrol1", persist:"location",collapsed:true});
					$(".deptclick").click(function ()
					{
						var nodeId = $(this).attr('value');
					//	alert(nodeId);
		  			 	$('#main',window.parent.document).attr("src","/ag/lwc/findOAContactByDept_OAContact.action?treeNodeId="+nodeId);
					});
					
					$("#find").click(function()
					{
						 var goal=document.getElementById("text").value; 
						 $("span:contains('"+goal+"')").css("color","red").css("font-size","20px").parents().show();
						 var set=$("span:contains('"+goal+"')");		//获取第一个匹配的元素
						 var first = set.first();	
						 if(set.size() != 0)
						  {
							 var y=first[0].offsetTop;		//获取第一个元素的y坐标
							 document.body.scrollTop=y-200;		
		
						  }
					});
	//清除查询	
					$("#clear").click(function(){
						$("span").css("color","").css("font-size","");
					});
			});
		</script>
	</head>

	<body style="background-image: url(../images/main_23_3.gif); background-repeat: repeat-y;">
		<div>
			<img src="../zhh/images/Arrow1 Left.gif" onclick="showHideFrame(-1)">
			<img src="../zhh/images/Arrow1 Right.gif" onclick="showHideFrame(1)">
		</div>
		<input type="text" id="text" class="input"><span style="width:20">&nbsp;</span><input type="button" id="find" value="查询" class="button"><input type="button" id="clear" value="清除" class="button">
		<%!public void printOATree(TreeNode node, ServletRequest request,
			ServletResponse response, JspWriter out) throws Exception {
		if (node != null) {
			out.println("<li><span class='deptclick' value='"+node.getNodeId()+"'>" + ((UserDept) node.getBindData()).getUdName()+"</span>");
			List childrenlist = node.getChildren();
			if (childrenlist.size() > 0) {
				out.println("<ul>");
				for (int i = 0; i < childrenlist.size(); i++) {
					TreeNode cnode = (TreeNode) childrenlist.get(i);
					printOATree(cnode, request, response, out);
				}
				out.println("</ul>");
			}
			out.println("</li>");
		}
	}%>
		<!-- 药监内部树(OA树) -->
		<div id="contree1">
			<div id="contreecontrol1">
				<a href="?#">关闭所有结点</a> |
				<a href="?#">打开所有节点</a> 
			</div>
			<div style="padding-top:3px;padding-left:75px;">
			<!--<input type="button" value="同步内部通信录" style="border:none;width:90px;height:25px;margin:2px;background-color:#c0c0c0;">  -->
			<!--<a href="/ag/lwc/OAsynchronism.action">同步内部通信录</a>-->
				
			</div> 
			<ul id="MedicineTree">
				<%
				TreeNode medicineTreeRoot=null;
				Object treeRootObj= request.getAttribute("OATreeRoot");
				if(treeRootObj!=null && !treeRootObj.getClass().equals(String.class)){
						 medicineTreeRoot = (TreeNode)treeRootObj;
				
					printOATree(medicineTreeRoot, request, response, out);
				
				}
			
				%>			
			</ul>
		</div>
		<script>
//step为框架尺寸改变的速度步长
//flag为判断当前状态是显示(1)还是隐藏(-1)
var obj,w,step=100,flag=-1;         
function showHideFrame(b){
		
       obj=parent.frames['treeFrameSet'];        //目标框架对象
       
      // alert(b);      
       w=parseInt(obj.cols.split(",")[0]);      
/*目标框架对象的当前宽度，本例中obj.cols取得的值为"100,*"(显示状态时为"0,*")，obj.cols.split(",")把 obj.cols以","为标志分组，得到数组["100","*"]，obj.cols.split(",")[0]取到数组的第一个元素100，然后用parseInt(obj.cols.split(",")[0])转化为整数*/
       flag=b;                //根据参数值b，设置显示隐藏状态
       resize();                //调用resize()函数
}
function resize(){
//调整目标框架对象宽度值，如果flag为1即显示框架时w不断变大，
//反之不断变小
		
       w += step*flag;
       if((flag==-1&&w>190)||(flag==1&&w<477)){
//隐藏状态并且w大于0或者显示状态并且w<100，执行下面的代码
		//alert(w);
          obj.cols=w+",6,*";                 //重设框架宽度
           //setTimeout("resize()",10); //10毫秒后再次执行resize()函数
       }
}
</script> 
	</body>
</html>
